package com.bawan.hrm.utils;

import com.bawan.hrm.model.User;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

import java.util.Map;

/**
 * Desc:
 * Author: zhengcongchun
 * CreateTime: 2014-05-21 14:03
 * LastModifyTime: 2014-05-21 14:03
 * FinalModifier: zhengcongchun
 * Version: 1.0
 */
public class AuthorityUtil extends AbstractInterceptor {
    @Override
    public String intercept(ActionInvocation invocation) throws Exception {
        ActionContext ctx = invocation.getInvocationContext();
        Map session = ctx.getSession();
        User user = (User) session.get("user");
        if(null != user){
            return invocation.invoke();
        }
        return "login";
    }
}
